package pl.model;

import java.util.List;

import org.apache.tapestry.form.IPropertySelectionModel;

public class CelebrityModel implements IPropertySelectionModel {

	 

	private List celebrities;

	public CelebrityModel(List celebrities) {

	  this.celebrities = celebrities;
	}

	@Override
	public String getLabel(int i) {

		Celebrity c = (Celebrity) celebrities.get(i);

		  return c.getFirstName() + " " + c.getLastName();
	}

	@Override
	public Object getOption(int i) {

		return celebrities.get(i);
	}

	@Override
	public int getOptionCount() {

		return celebrities.size();
	}

	@Override
	public String getValue(int i) {

		  return Integer.toString(i);
	}

	@Override
	public boolean isDisabled(int arg0) {

		return false;
	}

	@Override
	public Object translateValue(String value) {

		int index = Integer.parseInt(value);
		return celebrities.get(index);
	}

}
